<?php

namespace Restaurant\Controller;


use Core\Controller\RestaurantAdminBaseController;
use Core\Session\FrontSessionHelper;
use Exception;
use Zend\View\Model\JsonModel;

class IndexController extends RestaurantAdminBaseController {
    public function indexAction() {
        $this->initPageWithLayout();
        return $this->getViewModel();
    }

    public function changeLangAction(){
        try{
            $lang = $this->params()->fromPost('lang');
            FrontSessionHelper::setCurrentLang($lang);
            return new JsonModel(array(
                'success'=>true,
            ));

        }catch(Exception $e){
            $this->fireExceptionEvent($e, \Core\Constant::$EVENT_NAME_DISTRIBUTION_EXCEPTION);
            return $this->genJsonErrorView($e);
        }
    }
}